package com.wpml.ware.controller;

import com.wpml.common.util.PageUtils;
import com.wpml.common.util.ResultJson;
import com.wpml.ware.entity.WareInfoModel;
import com.wpml.ware.service.WareInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 仓库信息
 *
 * @author leifengyang
 * @email leifengyang@gmail.com
 * @date 2019-10-08 09:59:40
 */
@RestController
@RequestMapping("ware/wareinfo")
public class WareInfoController {
    @Autowired
    private WareInfoService wareInfoService;

    /**
     * 列表
     */
    @GetMapping("/list")
    //@RequiresPermissions("ware:wareinfo:list")
    public ResultJson list(@RequestParam Map<String, Object> params){
        PageUtils page = wareInfoService.queryPage(params);

        return ResultJson.ok(page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    //@RequiresPermissions("ware:wareinfo:info")
    public ResultJson info(@PathVariable("id") Long id){
		WareInfoModel wareInfo = wareInfoService.getById(id);

        return ResultJson.ok(wareInfo);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    //@RequiresPermissions("ware:wareinfo:save")
    public ResultJson save(@RequestBody WareInfoModel wareInfo){
		wareInfoService.save(wareInfo);

        return ResultJson.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    //@RequiresPermissions("ware:wareinfo:update")
    public ResultJson update(@RequestBody WareInfoModel wareInfo){
		wareInfoService.updateById(wareInfo);

        return ResultJson.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    //@RequiresPermissions("ware:wareinfo:delete")
    public ResultJson delete(@RequestBody Long[] ids){
		wareInfoService.removeByIds(Arrays.asList(ids));

        return ResultJson.ok();
    }

}
